﻿using System;
using System.Collections.Generic;
using UnityEngine;

namespace MyGame
{
    public enum ManagerType
    {
        GameManager,
        MapManager,
        AIManager,
        ChessManager,
        AssetsManager,
        YooAssetManager,
        UIManager,
    }

    public class GameManager : BaseManager<GameManager>
    {
        public Dictionary<ManagerType, GameObject> managerDictionary = new Dictionary<ManagerType, GameObject>();
        private readonly string[] managerNames = Enum.GetNames(typeof(ManagerType));

        public enum GameModel
        {
             none,
             pve,
             pvp,
        }

        public enum Executor
        {
            none,
            black,
            white,
        }

        private GameModel gameModel;
        
        private Executor executor;

        private bool IsGaming;
        public bool isGaming
        {
            get { return IsGaming; }
            set { IsGaming = value; }
        }

        private void Awake()
        {
            DontDestroyOnLoad(this);
            Application.targetFrameRate = 60;
        }

        private void Start()
        {
            isGaming = false;
            gameModel = GameModel.none;
            executor = Executor.none; 
        }

        public void StartGame()
        {
            isGaming = true;
            executor = Executor.black;

            Init();
        }

        public void Init()
        {
            AIManager.Instance.Init();
            ChessManager.Instance.Init();
            UIManager.Instance.Init();
            MapManager.Instance.Init();
            AssetsManager.Instance.Init();
        }

        public void EndGame()
        {
            GameOver();
        }

        public void GameOver()
        {
            if (isGaming)
            {
                isGaming = false;
                executor = Executor.none;
            }
        }

        public void SetExecutor(Executor _executor)
        {
            executor = _executor;
        }
        public Executor GetExecutor()
        {
            return executor;
        }

        public void SetGameModel(GameModel _gameModel)
        {
            gameModel = _gameModel;
            //Debug.Log("你选择了" + gameModel);
        }

        public GameModel GetGameModel()
        {
           return gameModel;
        }
    }
}

